import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

class Solution {
    //计算二叉树布尔的值
/*    public boolean evaluateTree(TreeNode root) {
        if(root.left == null) return root.val == 0 ?false : true;
        boolean left = evaluateTree(root.left);
        boolean right = evaluateTree(root.right);
        return root.val == 2?left || right:left&&right;
    }*/

    /* Write Code Here */
    public int calculateMaxTotalYie(int[][] cropField) {
      int m = cropField.length;
      int n = cropField[0].length;
      // int recrod1 = 0;
      // int recrod2 = 0;
      int recrod = 0;
      int max = 0;
      int l = 0;
      int c = 0;
      for(int i = 0;i<m;i++){
        recrod = 0;
        for(int j = 0;j<n;j++){
          for(int q = 0;q<n;q++){
            recrod+=cropField[i][q];
          }
          for(int w = 0;w<m;w++){
            recrod+=cropField[w][j];
          }
          recrod-=cropField[i][j];
          if(max < recrod) {
            max = recrod;
            l = i;
            c = j;
          }
        }
        
      }
      int sum = 0;
      for(int i = 0;i<m;i++){
        for(int j = 0;j<n;j++){
          if(i == l || j == c){
            sum+=(cropField[i][j]*2);
          }else{
            sum+=cropField[i][j];
          }
          
        }
      }
//      sum = sum - (cropField[l][c]*2);
      return sum;
    }

}

public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int res;
    
        int cropField_rows = 0;
        int cropField_cols = 0;
        cropField_rows = in.nextInt();
        cropField_cols = in.nextInt();
        
        int[][] cropField = new int[cropField_rows][cropField_cols];
        for(int cropField_i=0; cropField_i<cropField_rows; cropField_i++) {
            for(int cropField_j=0; cropField_j<cropField_cols; cropField_j++) {
                cropField[cropField_i][cropField_j] = in.nextInt();
            }
        }

        if(in.hasNextLine()) {
          in.nextLine();
        }


        res = new Solution().calculateMaxTotalYie(cropField);
        System.out.println(String.valueOf(res));    

    }
}
